const myUrl = getApp().globalData.myURL

Page({
  data: {
    src: ""
  },

  onShow: function() {
    wx.request({
      url: myUrl,
      data: {
        targetTemparture: '--graph'
      },
      success: res => {
        // console.log(res.data)
        if(res.data.startsWith('success: ')) {
          let base64Data = res.data.split(': ')[1]
          let temp1 = base64Data.substring(0, base64Data.length-1)
          let temp2 = temp1.substring(2, temp1.length)
          // console.log(temp2)
          this.setData({
            src: temp2
          })
        }
        else {
          console.log('something wrong:', res.data)
        }
      },
      fail: err => {
        console.log(err)
      }
    })
  }
})